
<script src="<?php echo base_url() ?>ckeditor/ckeditor.js"></script>
<script src="<?php echo base_url() ?>ckeditor/adapters/jquery.js"></script>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
 <script src="<?php echo base_url()?>assets/js/plugins/location_picker/jquery-gmaps-latlon-picker.js"></script>
<style>

#editable
{
	padding: 10px;
	float: left;
}

.gllpMap	{ width: 500px; height: 250px; }

.gllpLatlonPicker	{ margin: 20px 0; }

</style>
<script>

CKEDITOR.disableAutoInline = true;

$( document ).ready( function() {
      $( '#editor1' ).ckeditor(); // Use CKEDITOR.replace() if element is <textarea>.
      $( '#editor2' ).ckeditor(); // Use CKEDITOR.replace() if element is <textarea>.
      $( '#editable' ).ckeditor(); // Use CKEDITOR.inline().
  } );

function setValue() {
	$( '#editor1' ).val( $( 'input#val' ).val() );
	$( '#editor2' ).val( $( 'input#va2' ).val() );
}

</script>


<div id="page-wrapper">

<div class="container-fluid">

    <!-- Page Heading -->
    <div class="row">
        <div class="col-lg-12">
            <h1 class="page-header">
                Kelola Data Perusahaan
            </h1>
            <ol class="breadcrumb">
                <li>
                    <i class="fa fa-dashboard"></i>  <a href="<?php echo base_url(); ?>home">Dashboard</a>
                </li>
                <li class="active">
                    <i class="fa fa-edit"></i> Kelola Data Perusahaan
                </li>
                <li class="active">
                    <i></i> <a href="<?php echo base_url(); ?>modul/perusahaan">Data Prusahaan</a>
                </li>
            </ol>
        </div>
    </div>
    <!-- /.row -->
    <div class="col-lg-6">
        <h2>Edit perusahaan</h2><br>
        <?php $attributs = 'class="mws-form"'?>
        <?php echo form_open_multipart('modul/perusahaan/update', $attributs) ?>
            <form role="form">
            <?php foreach($perusahaan as $p): ?>
                <div class="form-group">
                    <label>Nama Perusahaan</label>
                    <span class="error"><font color="red"><?php echo form_error('nama_perusahaan'); ?></font></span>
                    <input class="form-control" name="nama_perusahaan" value="<?php echo $p->nama_perusahaan ?>">
                    <p class="help-block">Isi Dengan Teliti</p>
                </div>

                <div class="form-group">
                    <label>Bidang Usaha</label>
                    <span class="error"><font color="red"><?php echo form_error('kategori_perusahaan'); ?></font></span>
                    <select name="kategori_perusahaan" class="form-control">
                            <option value="penyedia jasa" <?php if($p->kategori_perusahaan=='penyedia jasa') echo"selected";?>>Penyedia Jasa</option>
                            <option value="penyedia barang" <?php if($p->kategori_perusahaan=='penyedia barang') echo"selected";?>>Penyedia Barang</option>
                            <option value="jual-beli" <?php if($p->kategori_perusahaan=='jual-beli') echo"selected";?>>Jual-Beli</option>
                            <option value="lainnya" <?php if($p->kategori_perusahaan=='lainnya') echo"selected";?>>Lainnya...</option>
                    </select>
                    <p class="help-block">Pilih salahsatu</p>
                </div>

                <div class="form-group">
                    <label>Alamat</label>
                    <span class="error"><font color="red"><?php echo form_error('alamat_perusahaan'); ?></font></span>
                    <textarea class="form-control" rows="3" name="alamat_perusahaan"><?php echo $p->alamat_perusahaan ?></textarea>
                </div>

                <div class="form-group">
                	<label>Tandai Map</label>
                	<fieldset class="gllpLatlonPicker">
						<input type="text" class="gllpSearchField">
						<input type="button" class="gllpSearchButton" value="search">
						<br/><br/>
						<div class="gllpMap">Google Maps</div>
						<br/>
							<input type="hidden" name="latitude_perusahaan" class="gllpLatitude" value="<?php echo $p->latitude_perusahaan ?>"/>
							<input type="hidden" name="longitude_perusahaan" class="gllpLongitude" value="<?php echo $p->longitude_perusahaan ?>"/>
							<input type="hidden" class="gllpZoom" value="12"/>
							<p class="help-block"><input type="text" class="gllpLocationName" size=60 disabled/></p>
						<br/>
					</fieldset>
				</div>

                <div class="form-group">
                    <label>kontak</label>
                    <?php foreach($kontak as $k): ?>
                    <div id="oldRow<?php echo $k->id_kontak ?>">
                    <span class="input-group-addon">
        				<select name="tipe_kontak[<?php echo $k->id_kontak ?>]" class="form-control">
                            <option value="mobile" <?php if($k->tipe_kontak=='mobile') echo"selected";?>>Mobile</option>
                            <option value="home" <?php if($k->tipe_kontak=='home') echo"selected";?>>Home</option>
                            <option value="fax" <?php if($k->tipe_kontak=='fax') echo"selected";?>>Fax</option>
                            <option value="email" <?php if($k->tipe_kontak=='email') echo"selected";?>>Email</option>
                            <option value="other" <?php if($k->tipe_kontak=='other') echo"selected";?>>Other</option>
                        </select>
                    </span>
                    <input type="text" name="kontak[<?php echo $k->id_kontak ?>]" class="form-control" value="<?php echo $k->kontak ?>">
                    <p class="help-block"> <input type="checkbox" name="delete_ids[]" value="<?php echo $k->id_kontak ?>">Hapus </p> 
                    </div>                    
					<?php endforeach ?> 
					<div id="itemrow"></div>
                    <p class="help-block"><input type="button" class="btn btn-sm btn-success" onclick="addRow()" value="Tambah Kontak"></p>               
                </div>

                <div class="form-group">
                    <label>Keterangan</label>
                    <span class="error"><font color="red"><?php echo form_error('keterangan_perusahaan'); ?></font></span>
                    <textarea class="form-control" rows="3" name="keterangan_perusahaan"><?php echo $p->keterangan_perusahaan ?></textarea>
                </div>
              	<?php echo form_hidden('id_perusahaan', $p->id_perusahaan);?>
            <?php endforeach ?>

                <div class="form-group">
                    <button type="submit" class="btn btn-default">Submit</button>
                    <button type="reset" class="btn btn-default">Reset</button>
                </div>
    <!-- /.row -->

</div>
            <!-- /.container-fluid -->

<?php echo form_close()?>


 <script>
  var rowNum = 1;

  function addRow(){
        rowNum ++;
        var row = '<div id="rowNum'+rowNum+'"><span class="input-group-addon"><select name="tipe_kontak['+rowNum+']" class="form-control"><option value="mobile">Mobile</option><option value="home">Home</option><option value="fax">Fax</option><option value="email">Email</option><option value="other">Other</option></select></span><input type="text" name="kontak['+rowNum+']" class="form-control" ><p class="help-block"> <input type="button" class="btn btn-sm btn-danger" value="Hapus" onclick="removeRow('+rowNum+');"></p></div>';
        $('#itemrow').append(row);
    }

  function removeRow(rnum) {
    $('#rowNum'+rnum).remove();
  }

  </script>